package hzjbbis.commons.maintenance.action;

import hzjbbis.commons.maintenance.dao.SingleTableDao;
import hzjbbis.commons.maintenance.handler.TempletStandard;
import hzjbbis.commons.maintenance.handler.request.QueryRequestHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * @version 	1.0
 * @author
 */
public class NewNodeAction extends Action {
	public static final Log logger = LogFactory.getLog(NewNodeAction.class);

	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {

		QueryRequestHandler requestHandler =
			new QueryRequestHandler(
				request,
				TempletStandard.NEW_NODE_KEY_HANDLER);

		Object resultGrid = SingleTableDao.executeHandler(requestHandler);

		request.setAttribute("xml", resultGrid.toString());

		request.setAttribute(
			"pidColumnName",
			requestHandler.getPidColumnName());

		logger.debug(resultGrid);

		return mapping.findForward("success");
	}
}
